
#include<iostream>

void swap0(int a, int b)
{
    int tmp = a;
    a = b;
    b = tmp;
    std::cout << "swap0 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;
}

void swap1(int &a, int &b)
{
    int tmp = a;
    a = b;
    b = tmp;
    std::cout << "swap1 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;
}

void swap2(int* a, int* b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
    std::cout << "swap2 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;
}

int main()
{
    int a = 9;
    int b = 8;
    std::cout << "init0 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;
    swap0(a, b);
    std::cout << "swap0 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;

    swap1(a, b);
    std::cout << "swap1 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;

    swap2(&a, &b);
    std::cout << "swap2 a = " << a << ", b = " << b << ", &a = "<< &a <<", &b = "<< &b << std::endl;

    return 0;
}
